<?php 
//授课工作量
$menu='teachhour';
include_once 'head.php';
include_once 'dbconfig.php';
//先查年度
$sql = "select * from basedata3 where id=1";
$pdoStatment = $pdo->prepare($sql);
$ret = $pdoStatment->execute();
$year = date("Y");
if($ret){
	$resultYear = $pdoStatment->fetch(PDO::FETCH_ASSOC);
	$year = $resultYear['content'];
}

//要求准备语句的命名参数
$sql = "select teachhour.id,teachhour.year,teachhour.teacherId,user.name,teachhour.classHour,teachhour.status".
    " from teachhour join user on userId=teacherId";
$pdoStatment = $pdo->prepare($sql);
$ret = $pdoStatment->execute();
if($ret){
    $result = $pdoStatment->fetchAll(PDO::FETCH_ASSOC);
}

?> 
        <!-- /. NAV SIDE  -->
        <div id="page-wrapper" >
            <div id="page-inner">
            	<div class="clearfix"></div>
			<div class="searchbody">
				<form method='post' action='myteachhour.php'>
					<div class="mytype">
						<p class="mytype-title">年度：</p>
						<select class="mytype-item" name="year" width=30>
						<option value="0" >全部</option>
						<option value="2018" >2018年</option>
						<option value="2019" >2019年</option>
						<option value="2020" selected>2020年</option>
						<option value="2021" >2021年</option>
						<option value="2022" >2022年</option>
					  </select>
					</div>
					<div class="querybtn">
						<input type='submit' value='查询' />
					</div>
					<div class="clearfix"></div>
				</form>
			</div>
	
               
            <div class="row">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                           <a href='insertteachhour.php'  class="btn btn-primary">新增教学工作量</a>
                        </div>
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>id</th>
                                            <th>年度</th>
                                            <th>教工号</th>
                                            <th>姓名</th>
                                            <th>学时数</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    	<?php 
                                    	$line = 1;
                                    	foreach ($result as $row){
                                    		if($line%2==1){
                                    			echo '<tr class="odd gradeX">';
                                    		}else{
                                    			echo '<tr class="even gradeC">';
                                    		}
                                    		$line++;
                                    		echo "<td>".$row['id']."</td>";
                                    		echo "<td>".$row['year']."</td>";
                                    		echo "<td>".$row['teacherId']."</td>";
                                    		echo "<td>".$row['name']."</td>";
                                    		echo "<td>".$row['classHour']."</td>";
                                    		echo "<td>".$row['status']."</td>";
                                    		    $url = "editteachhour2.php?id=" . $row ['id'];
                                    		    $delurl = "deleteteachhour2.php?id=" . $row ['id'];
                                    		    echo "<td><a class='btn btn-primary btn-sm shiny' href='" . $url . "'><i class='fa fa-edit'>&nbsp;编辑</i></a>&nbsp;&nbsp;";
                                    		    echo "<a class='btn btn-danger btn-sm shiny' href='" . $delurl . "'><i class='fa fa-trash-o'>&nbsp;删除</i></a></td>";
                                    	}
                                    	?> 
                                    </tbody>
                                </table>
                            </div>
                            
                        </div>
                    </div>
                    <!--End Advanced Tables -->
                </div>
            </div>
        </div> 
             <!-- /. PAGE INNER  -->
            </div>
         <!-- /. PAGE WRAPPER  -->
     <!-- /. WRAPPER  -->
    <!-- SCRIPTS -AT THE BOTOM TO REDUCE THE LOAD TIME-->
    <!-- JQUERY SCRIPTS -->
    <script src="assets/js/jquery-1.10.2.js"></script>
      <!-- BOOTSTRAP SCRIPTS -->
    <script src="assets/js/bootstrap.min.js"></script>
    <!-- METISMENU SCRIPTS -->
    <script src="assets/js/jquery.metisMenu.js"></script>
     <!-- DATA TABLE SCRIPTS -->
    <script src="assets/js/dataTables/jquery.dataTables.js"></script>
    <script src="assets/js/dataTables/dataTables.bootstrap.js"></script>
        <script>
            $(document).ready(function () {
                $('#dataTables-example').dataTable();
            });
    </script>
         <!-- CUSTOM SCRIPTS -->
    <script src="assets/js/custom.js"></script>
    
   
</body>
</html>
